#include "dlog/restream.h"

namespace util {
namespace dlog {
namespace format {

const char *log_types[] = {"DEBUG", "INFO", "WARN", "ERROR", "FATAL"};

std::string get_head(const char *filename, const size_t &line_number,
                     const size_t &log_level) {
  std::stringstream head_ss;
  time_t tm;
  time(&tm);
  auto time_tm = localtime(&tm);
  char time_tmp[128];
  strftime(time_tmp, 128, "%F %T", time_tm);
  head_ss << '[' << log_types[log_level] << ']' << '[' << filename << ':'
          << line_number << ']' << '[' << time_tmp << ']';
  return head_ss.str();
}

} // namespace format
} // namespace dlog
} // namespace util
